import { Checkbox } from 'antd';
import type { CheckboxValueType } from 'antd/es/checkbox/Group';
import styles from './index.less';
const CheckboxGroup = Checkbox.Group;

const CheckedList = (props: any) => {
  const { options = [], value = [], onChange, isRadio } = props;
  //多选
  const _groupChange = async (list: CheckboxValueType[]) => {
    onChange(isRadio ? [list[list.length - 1]] : list);
  };
  return (
    <div style={{ padding: 16, overflowY: 'scroll', height: 190 }}>
      <CheckboxGroup className={styles.group} value={value} onChange={_groupChange}>
        {options.map((t: any, i: number) => (
          <Checkbox value={t.value} className={styles.check_flex} key={i}>
            <div>{t.label}</div>
          </Checkbox>
        ))}
      </CheckboxGroup>
    </div>
  );
};
export default CheckedList;
